package org.WhyMCA.Utils;

/**
@author Danilo '' Riso >> danilo DOT riso AT gmail DOT com
* @author Androidiani Dev Team
* @version 1.0
*/

import org.WhyMCA.WhyMCANews.R;
import org.WhyMCA.Utils.Global;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class DialogMgr extends Dialog implements OnClickListener {
		
	public interface DialogCallback {
		/**
		 * Chiamato quando viene premuto uno dei bottoni
		 * @param result true se il tasto era ok false altrimenti
		 */
		public void onDialogClicked(boolean result);
	}
	
	public DialogMgr(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public static void noNetworkAlert(final DialogCallback cback) {
		
		new AlertDialog.Builder(Global.getCtx())
		.setCancelable(false)
		.setIcon(R.drawable.alert_dialog_icon)
		.setTitle(R.string.network_alert_dialog_title)
		.setMessage(R.string.network_alert_dialog)
		.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				
				if (cback != null) {
                //	cback.onDialogClicked(true);
					cback.onDialogClicked(false);
                }
				
			}
		})
		.create()
		.show();
	
	}
			
	public static void dialogConnError(final DialogCallback cback) {
		
		new AlertDialog.Builder(Global.getCtx())
		.setCancelable(true)
		.setIcon(R.drawable.alert_dialog_icon)
		.setTitle(R.string.error_network_dialog_title)
		.setMessage(R.string.error_network_dialog_text)
		.setNeutralButton(R.string.ok_button, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				
				if (cback != null) {
                	cback.onDialogClicked(false);
                }
				
			}
		})
		.create()
		.show();
		
	}
   
	/*public static void dialogChangelog() {
		
		LayoutInflater factory = LayoutInflater.from(Global.getCtx());
		final View _alert = factory.inflate(R.layout.dialog_changelog, null);
		
		new AlertDialog.Builder(Global.getCtx())
		.setCancelable(true)
		.setIcon(R.drawable.alert_dialog_icon)
		.setTitle(R.string.changelog_title)
		.setView(_alert)
		.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				
				
				
			}
		})
		.create()
		.show();
		
	}
	
	public void dialogSessionTerminated(final DialogCallback cback, String obj) {
		
		LayoutInflater factory = LayoutInflater.from(Global.getCtx());
		final View _alert = factory.inflate(R.layout.dialog_session_terminated, null);
		
		new AlertDialog.Builder(Global.getCtx())
		.setCancelable(true)
		.setIcon(R.drawable.alert_dialog_icon)
		.setTitle(obj)
		.setView(_alert)
		.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				
				if (cback != null) {
                	cback.onDialogClicked(true, "next");
                }
				
			}
		})
		.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				
				if (cback != null) {
                	cback.onDialogClicked(false, "demo");
                }
				
			}
		})
		.create()
		.show();
		
	}*/

	@Override
	public void onClick(DialogInterface dialog, int which) {
		
		
	}
	
}
